<?php
/**
 *
 * @author Tran Minh Quang
 * @version 
 */

class Zend_View_Helper_LoadSkin extends Zend_View_Helper_Layout
{
    /**
     * Loads the skin.xml file and returns each stylesheet to the view
     *
     * @param string $skin Skin to use
     */
    public function loadSkin($skin)
    {
        // First, load the skin configuration file
        $skinData = new Zend_Config_Xml(APPLICATION_PATH . '/../public/skins/' . $skin . '/skin.xml');
        $styleSheets = $skinData->stylesheets->stylesheet->toArray();
        // Now, append each stylesheet defined in skin.xml
        if(is_array($styleSheets)) {
        	$i = 1;
            foreach($styleSheets as $styleSheet) {
                $pathStyle = '/skins/' . $skin . '/css/' . trim($styleSheet);
                $this->view->headLink()->appendStylesheet($this->view->baseUrl() . $pathStyle);
                
            }
            echo $this->view->headLink();
        }
    }
}
